import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

import 'package:get/get.dart';
import 'package:zrjz/comm/utils/ex_widget.dart';
import 'package:zrjz/generated/assets.dart';

import '../../constants/color_constants.dart';
import '../my_load_image.dart';
import '../my_text_view.dart';

/// 打印调试信息，点击可以复制弹窗的文本
class PrintInfoDialog extends StatelessWidget {
  String? message;

  PrintInfoDialog(this.message);

  @override
  Widget build(BuildContext context) {
    GlobalKey _textKey = GlobalKey();

    return Container(
      decoration: const BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(5)),
      ),
      child: SingleChildScrollView(
        child: RepaintBoundary(
          key: _textKey,
          child: MyTextView(
            message ?? '',
            fontSize: 14,
            textColor: ColorConstants.black33,
            isFontRegular: true,
            textAlign: TextAlign.center,
            paddingLeft: 30,
            paddingRight: 30,
            paddingBottom: 35,
            marginTop: 35,
            onClick: () {
              Clipboard.setData(ClipboardData(text: message ?? ''));
              SmartDialog.showToast('复制成功');
            },
          ),
        ),
      ),
    ).constrained(width: 300, maxHeight: 500);
  }

  //取消弹框
  void onCancel() async {
    SmartDialog.dismiss();
  }
}
